﻿using DevExpress.Web.ASPxEditors;
using DevExpress.Web.ASPxGridView;
using Kaysite.Controller;
using Kaysite.Manager;
using Kaysite.Model;

public partial class Controls_AdminControls_UserList : BaseListControl<UserController, User>
{
    public override ASPxGridView GridView
    {
        get { return gridList; }
    }

    public override ASPxButton AddButton
    {
        get { return btnAdd; }
    }

    public override string GetEditPopupTitle(bool isEdit = false)
    {
        return "працівника";
    }

    protected override void DoDelete(int pID)
    {
        var manager = CreateManager<UserManager>();
        var model = manager.InitializeModel(pID);
        if (model==null)
            return;
        model.StatusID = eUserStatus.Disabled;
        manager.Save();
    }
    protected void gridList_HtmlRowPrepared(object sender, ASPxGridViewTableRowEventArgs e)
    {
        if (e.RowType == GridViewRowType.Data)
        {
            var role = (eRole)e.GetValue("RoleID");
            if (role == eRole.Admin)
                e.Row.ControlStyle.Font.Bold = true;
        }
    }
}